package com.shaobufan.museum.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class PhotoUtils implements WebMvcConfigurer {

    @Value("${bmp.path:{null}}")
    private String bmpPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /*
          "/image/**" 为前端URL访问路径
          "file:" + bmpPath 是本地磁盘映射
         */
        registry.addResourceHandler("/image/**").addResourceLocations("file:" + bmpPath);
    }
}